package admin_role

import (
	"context"
	adminRoleApi "go-skeleton/api/admin/service/admin_role"
	"go-skeleton/app/admin/service/internal/biz"
	"google.golang.org/protobuf/types/known/emptypb"
)

type RoleService struct {
	adminRoleApi.UnimplementedRoleServiceServer

	m *biz.AdminRoleBiz
}

func NewRoleService(m *biz.AdminRoleBiz) *RoleService {
	return &RoleService{m: m}
}

func (s *RoleService) GetRole(ctx context.Context, req *adminRoleApi.GetRoleRequest) (resp *adminRoleApi.GetRoleReply, err error) {
	return s.m.GetRole(ctx, req)
}

func (s *RoleService) GetAllRole(ctx context.Context, req *emptypb.Empty) (resp *adminRoleApi.GetAllRoleReply, err error) {
	return s.m.GetAllRole(ctx)
}

func (s *RoleService) AddRole(ctx context.Context, req *adminRoleApi.RoleInfo) (resp *adminRoleApi.RoleInfo, err error) {
	return s.m.Save(ctx, req)
}

func (s *RoleService) EditRole(ctx context.Context, req *adminRoleApi.RoleInfo) (resp *adminRoleApi.RoleInfo, err error) {
	return s.m.Update(ctx, req)
}

func (s *RoleService) DelRole(ctx context.Context, req *adminRoleApi.RoleInfo) (resp *emptypb.Empty, err error) {
	return s.m.DelRole(ctx, req.Id)
}
